package org.example.struct.array;

import java.util.HashSet;
import java.util.Set;

/**
 * @author liyishan
 * @date 2024/8/14 09:47
 * @apiNote
 */

public class Test00824ToGoatLatin {
    public String toGoatLatin(String sentence) {
        Set<Character> set = new HashSet<>();
        set.add('a');
        set.add('e');
        set.add('i');
        set.add('o');
        set.add('u');
        String[] s = sentence.split(" ");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length; i++) {
            if(set.contains(Character.toLowerCase(s[i].charAt(0)))){
                sb.append(s[i]).append("ma");
            }else{
                sb.append(s[i].substring(1)).append(s[i].charAt(0)).append("ma");
            }
            for(int j = 0;j<i+1;j++){
                sb.append("a");
            }
            sb.append(" ");
        }
        return sb.toString().trim();
    }
}
